import * as types from '../constants/ActionTypes';

export default function wxupgrade(state = [], action = {}) {
    const {
        type, payload
    } = action;

    switch (type) {
       
        case types.WXUPGRADE:
            
            return { ...payload };

        case types.WXUPGRADE_SUCCESS:
            let successInfo = null;
            if (payload.results && payload.results.length) {
                successInfo = {
                    wxupgrade2_status : 1,
                    message : "完善资料成功"
                };
            }else{
                successInfo = {
                    wxupgrade2_status: 0,
                    message: "完善资料失败"
                }
            }
            return {
               ...state,
               ...successInfo
            };   
        case types.WXUPGRADE_FAILURE:
            let failureInfo = {
                wxupgrade2_status: -1,
                message: payload.message||'网络连接失败'
            };
            return {
               ...state,
               ...failureInfo
            };  
        default:
            return state;
    }
}